package com.ssb.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.ssb.po.Order;
import com.ssb.po.OrderExample;
import com.ssb.service.OrderService;

/**
 * 查询订单
 * 
 * @author 胡俊 2016年10月5日 下午6:44:25
 */
@Controller
public class OrderController {
	@Autowired
	OrderService orderService;

	@RequestMapping("/selPhone")
	public String selPhone(String phone,Model m) {
		OrderExample example = new OrderExample();
		example.createCriteria().andPhoneEqualTo(phone);
		List<Order> orders = orderService.selectByExample(example);
		m.addAttribute("orders", orders);
		return "wx/order";
	}

	/**
	 * 后台查询所有代发货订单
	 * 
	 * @return
	 */
	@RequestMapping("/selOrderDai")
	public String selAllDaiOrder(Model m) {
		OrderExample example = new OrderExample();
		example.createCriteria().andStatusEqualTo(0);
		List<Order> orders = orderService.selectByExample(example);
		m.addAttribute("orders",orders);
		return "wxht/order";
	}

	/**
	 * 后台查询所有已发货订单
	 * 
	 * @return
	 */
	@RequestMapping("/selOrderYi")
	public String selAllOrderGo(Model m) {
		OrderExample example = new OrderExample();
		example.createCriteria().andStatusEqualTo(1);
		List<Order> orders = orderService.selectByExample(example);
		m.addAttribute("orders",orders);
		return "wxht/order";
	}

	/**
	 * 取得发货订单兵跳转到物流信息页面
	 */
	@RequestMapping("/fahuo0/dd")
	public String fahuo0(Order order) {
		return "wxht/adress";
	}

	/**
	 * 发货
	 * 
	 * @return
	 */
	@RequestMapping("/fahuo/ss")
	public String fahuo(Order order) {
		orderService.updateByPrimaryKeySelective(order);
		return "success";
	}

}
